

#include "BSP_Delay.h"
#include "CpuDelay.h"

void BSP_Delay_ns(unsigned int ns_100)
{
	for (; ns_100 > 0; ns_100--) {
		NP();
		NP();
		NP();
	}
}


/*while循环本身有5条指令，加上103条NOP指令，一个循环108条指令，大约1us*/
void BSP_Delay_us(unsigned int us)
{
	CPU_Delay(us);
}


void BSP_Delay_ms(unsigned int ms)
{
	CPU_Delay(ms * 1000);
}

#if 0
#define DLY_Timer		TIMER3

static void delay_timer_config(void){
    timer_parameter_struct timer_initpara;

    rcu_periph_clock_enable(RCU_TIMER3);

    timer_deinit(DLY_Timer);
    /* initialize TIMER init parameter struct */
    timer_struct_para_init(&timer_initpara);
    /* TIMER1 configuration */
    timer_initpara.prescaler         = 108 - 1;
    timer_initpara.alignedmode       = TIMER_COUNTER_EDGE;
    timer_initpara.counterdirection  = TIMER_COUNTER_UP;
    timer_initpara.period            = 0xFFFF;
    timer_initpara.clockdivision     = TIMER_CKDIV_DIV1;
    timer_init(DLY_Timer, &timer_initpara);

    timer_enable(DLY_Timer);
}
#endif 


void BSP_StrictDelay_Init(void){
//		delay_timer_config();
}

void BSP_StrictDelay_us(uint16_t us){
	CPU_Delay(us);
}


